Soru & Cevap

Fragmentten Fragmente Geçiş

03.02.2017 - 11:48

Bir activity (EmsileMuhtelifeAnasayfa.java) içinde bulunan butona tıklayarak hem farklı bi activity (CekimlerMain.java) açılmasını hem de açılan avtivty içinde bulunan Viewpager itemini değiştirmek istiyorum.

Viewpager içindeki sayfalar "nasara", "yensuru" diye sırayla bulunuyor. Ben butona tıklayınca ikinci sıradaki "yensuru" ekrana gelsin istiyorum.

EmsileMuhtelifeAnasayfa (Activity)

package com.fanaa1986.emsilekitabi;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.NavigationView;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.TextView;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

public class EmsileMuhtelifeAnasayfa extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    public ViewPager mViewPager;
    public Adapter mAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mAdapter = new Adapter(getSupportFragmentManager());
        mViewPager = (ViewPager) findViewById(R.id.container);
        mViewPager.setAdapter(mAdapter);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open,
                R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
    }

    public boolean onKeyDown(int keyCode, KeyEvent event){

        if(keyCode==KeyEvent.KEYCODE_BACK){
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
            if (drawer.isDrawerOpen(GravityCompat.START)){
                drawer.closeDrawer(GravityCompat.START);
            }else {
                Intent intent = new Intent(getApplicationContext(), AnasayfaGiris.class);
                startActivity(intent);
                overridePendingTransition(R.anim.anim_cikis, R.anim.anim_giris);
                finish();
            }
        }
        return super.onKeyDown(keyCode, event);
    }

    public static class GirisAnasayfa extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public GirisAnasayfa(){
        }

        public static GirisAnasayfa newInstance(int sectionNumber) {
            GirisAnasayfa girisAnasayfa = new GirisAnasayfa();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            girisAnasayfa.setArguments(args);
            return girisAnasayfa;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
             View sayfa = inflater.inflate(R.layout.emsilemuhtelife_anasyafa, container, false);

            AdView reklam=(AdView) sayfa.findViewById(R.id.emsilemuhtelife_reklam);
            AdRequest reklam_request= new AdRequest.Builder()
                    .addTestDevice("353975070582289")
                    .build();
            reklam.loadAd(reklam_request);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            Button nasara= (Button) sayfa.findViewById(R.id.nasara);
            nasara.setTypeface(arabca_font);

            final Button yensuru= (Button) sayfa.findViewById(R.id.yensuru);
            yensuru.setTypeface(arabca_font);

            Button nasran= (Button) sayfa.findViewById(R.id.nasran);
            nasran.setTypeface(arabca_font);

            Button fehuvenasirun= (Button) sayfa.findViewById(R.id.fehuvenasirun);
            fehuvenasirun.setTypeface(arabca_font);

            Button vezakemensurun= (Button) sayfa.findViewById(R.id.vezakemensurun);
            vezakemensurun.setTypeface(arabca_font);

            Button lemyensur= (Button) sayfa.findViewById(R.id.lemyensur);
            lemyensur.setTypeface(arabca_font);

            Button lemmayensur= (Button) sayfa.findViewById(R.id.lemmayensur);
            lemmayensur.setTypeface(arabca_font);

            Button mayensuru= (Button) sayfa.findViewById(R.id.mayensuru);
            mayensuru.setTypeface(arabca_font);

            Button layensuru= (Button) sayfa.findViewById(R.id.layensuru);
            layensuru.setTypeface(arabca_font);

            Button lenyensura= (Button) sayfa.findViewById(R.id.lenyensura);
            lenyensura.setTypeface(arabca_font);

            Button liyensur= (Button) sayfa.findViewById(R.id.liyensur);
            liyensur.setTypeface(arabca_font);

            Button layensur= (Button) sayfa.findViewById(R.id.layensur);
            layensur.setTypeface(arabca_font);

            Button unsur= (Button) sayfa.findViewById(R.id.unsur);
            unsur.setTypeface(arabca_font);

            Button latensur= (Button) sayfa.findViewById(R.id.latensur);
            latensur.setTypeface(arabca_font);

            Button menserun= (Button) sayfa.findViewById(R.id.menserun);
            menserun.setTypeface(arabca_font);

            Button minserun= (Button) sayfa.findViewById(R.id.minserun);
            minserun.setTypeface(arabca_font);

            Button nasreten= (Button) sayfa.findViewById(R.id.nasreten);
            nasreten.setTypeface(arabca_font);

            Button nisreten= (Button) sayfa.findViewById(R.id.nisreten);
            nisreten.setTypeface(arabca_font);

            Button nuseyrun= (Button) sayfa.findViewById(R.id.nuseyrun);
            nuseyrun.setTypeface(arabca_font);

            Button nasriyyun= (Button) sayfa.findViewById(R.id.nasriyyun);
            nasriyyun.setTypeface(arabca_font);

            Button nassarun= (Button) sayfa.findViewById(R.id.nassarun);
            nassarun.setTypeface(arabca_font);

            Button ensaru= (Button) sayfa.findViewById(R.id.ensaru);
            ensaru.setTypeface(arabca_font);

            Button maensarahu= (Button) sayfa.findViewById(R.id.maensarahu);
            maensarahu.setTypeface(arabca_font);

            Button veensirbihi= (Button) sayfa.findViewById(R.id.veensirbihi);
            veensirbihi.setTypeface(arabca_font);

            Animation oynat= AnimationUtils.loadAnimation(getActivity(),
                    R.anim.saydam_animasyon);

            nasara.startAnimation(oynat);
            yensuru.startAnimation(oynat);
            nasran.startAnimation(oynat);
            fehuvenasirun.startAnimation(oynat);
            vezakemensurun.startAnimation(oynat);
            lemyensur.startAnimation(oynat);
            lemmayensur.startAnimation(oynat);
            mayensuru.startAnimation(oynat);
            layensuru.startAnimation(oynat);
            lenyensura.startAnimation(oynat);
            liyensur.startAnimation(oynat);
            layensur.startAnimation(oynat);
            unsur.startAnimation(oynat);
            latensur.startAnimation(oynat);
            menserun.startAnimation(oynat);
            minserun.startAnimation(oynat);
            nasreten.startAnimation(oynat);
            nisreten.startAnimation(oynat);
            nuseyrun.startAnimation(oynat);
            nasriyyun.startAnimation(oynat);
            nassarun.startAnimation(oynat);
            ensaru.startAnimation(oynat);
            maensarahu.startAnimation(oynat);
            veensirbihi.startAnimation(oynat);

            nasara.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), CekimlerMain.class);
                    startActivity(intent);
                    getActivity().finish();

                }
            });

            yensuru.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity().getApplicationContext(), CekimlerMain.class);
                    startActivity(intent);
                }
            });

            return sayfa;
        }
    }

    public class Adapter extends FragmentPagerAdapter {
        Adapter (FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            return GirisAnasayfa.newInstance(position + 1);
        }

        @Override
        public int getCount() {
            return 1;
        }
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }


    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(@NonNull MenuItem item) {

        Typeface font = Typeface.createFromAsset(getAssets(), "fonts/araptype.ttf");

        TextView muhtelife = (TextView) findViewById(R.id.menu_muhtelife);
        muhtelife.setTypeface(font);

        TextView mutteride = (TextView) findViewById(R.id.menu_mutteride);
        mutteride.setTypeface(font);

         int id = item.getItemId();

        if (id == R.id.menu_anasayfa) {
            Intent intent = new Intent(getApplicationContext(), AnasayfaGiris.class);
            startActivity(intent);
            finish();
        } else if (id == R.id.menu_muhtelife) {

        } else if (id == R.id.menu_mutteride) {
            Intent intent = new Intent(getApplicationContext(), EmsileMutterideAnasayfa.class);
            startActivity(intent);
            finish();
        } else if (id == R.id.menu_cikis) {
            AlertDialog.Builder diyalog = new AlertDialog.Builder(this);
            diyalog.setIcon(android.R.drawable.ic_dialog_alert);
            diyalog.setTitle(R.string.alertdiyalog_uyari);
            diyalog.setCancelable(false);
            diyalog.setMessage(R.string.alertdiyalog_soru);
            diyalog.setPositiveButton(R.string.alertdiyalog_evet,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            finish();
                        }
                    });
            diyalog.setNegativeButton(R.string.alertdiyalog_hayir, null).show();
        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
}

CekimlerMain (ACTİVİTY) 

package com.fanaa1986.emsilekitabi;

import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.NavigationView;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;

public class CekimlerMain extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    public ViewPager viewPager;
    public SectionsPagerAdapter adapter;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cekimler_main);

        AdView reklam=(AdView) findViewById(R.id.cekimlermain_reklam);
        AdRequest reklam_request= new AdRequest.Builder()
                .addTestDevice("353975070582289")
                .build();
        reklam.loadAd(reklam_request);

        View.OnClickListener listener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (v == findViewById(R.id.yensuru)){
                    Fragment fragment = null;
                    getSupportFragmentManager().beginTransaction().replace(R.id.container2, fragment).commit();
                }else{

                }
            }
        };

        adapter = new SectionsPagerAdapter(getSupportFragmentManager());
        viewPager = (ViewPager) findViewById(R.id.container2);
        viewPager.setAdapter(adapter);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_cekimler);
        setSupportActionBar(toolbar);

        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
        tabLayout.setupWithViewPager(viewPager);

        DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.cekim_drawer_layout);

        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawerLayout, toolbar, R.string.navigation_drawer_open,
                R.string.navigation_drawer_close);
        drawerLayout.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.cekimler_nav_view);
        navigationView.setNavigationItemSelectedListener(this);
    }

    public boolean onKeyDown(int keyCode, KeyEvent event){

        if(keyCode==KeyEvent.KEYCODE_BACK){
            DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.cekim_drawer_layout);
            if (drawerLayout.isDrawerOpen(GravityCompat.START)){
                drawerLayout.closeDrawer(GravityCompat.START);
            }else {
                Intent intent = new Intent(getApplicationContext(), EmsileMuhtelifeAnasayfa.class);
                startActivity(intent);
                overridePendingTransition(R.anim.anim_cikis, R.anim.anim_giris);
                finish();
            }
        }
        return super.onKeyDown(keyCode, event);
    }

    public static class CekimlerNasara extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerNasara(){
        }

        public static CekimlerNasara newInstance(int sectionNumber) {
            CekimlerNasara cekimlerNasara = new CekimlerNasara();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerNasara.setArguments(args);
            return cekimlerNasara;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.nasara_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.nasara_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerYensuru extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerYensuru(){
        }

        public static CekimlerYensuru newInstance(int sectionNumber) {
            CekimlerYensuru cekimlerYensuru = new CekimlerYensuru();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerYensuru.setArguments(args);
            return cekimlerYensuru;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.yensuru_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.yensuru_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerNasran extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerNasran(){
        }

        public static CekimlerNasran newInstance(int sectionNumber) {
            CekimlerNasran cekimlerNasran = new CekimlerNasran();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerNasran.setArguments(args);
            return cekimlerNasran;
        }
        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.nasran_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.nasran_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerFehuvenasirun extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerFehuvenasirun(){
        }

        public static CekimlerFehuvenasirun newInstance(int sectionNumber) {
            CekimlerFehuvenasirun cekimlerFehuvenasirun = new CekimlerFehuvenasirun();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerFehuvenasirun.setArguments(args);
            return cekimlerFehuvenasirun;
        }
        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.fehuvenasirun_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.fehuvenasirun_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerVezakemensurun extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerVezakemensurun(){
        }

        public static CekimlerVezakemensurun newInstance(int sectionNumber) {
            CekimlerVezakemensurun cekimlerVezakemensurun = new CekimlerVezakemensurun();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerVezakemensurun.setArguments(args);
            return cekimlerVezakemensurun;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.vezakemensurun_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.vezakemensurun_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerLemyensur extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerLemyensur(){
        }

        public static CekimlerLemyensur newInstance(int sectionNumber) {
            CekimlerLemyensur cekimlerLemyensur = new CekimlerLemyensur();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerLemyensur.setArguments(args);
            return cekimlerLemyensur;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.lemyensur_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.lemyensur_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerLemmayensur extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerLemmayensur(){
        }

        public static CekimlerLemmayensur newInstance(int sectionNumber) {
            CekimlerLemmayensur cekimlerLemmayensur = new CekimlerLemmayensur();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerLemmayensur.setArguments(args);
            return cekimlerLemmayensur;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.lemmayensur_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.lemmayensur_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerMayensuru extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerMayensuru(){
        }

        public static CekimlerMayensuru newInstance(int sectionNumber) {
            CekimlerMayensuru cekimlerMayensuru = new CekimlerMayensuru();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerMayensuru.setArguments(args);
            return cekimlerMayensuru;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.mayensuru_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.mayensuru_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerLayensuru extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerLayensuru(){
        }

        public static CekimlerLayensuru newInstance(int sectionNumber) {
            CekimlerLayensuru cekimlerLayensuru = new CekimlerLayensuru();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerLayensuru.setArguments(args);
            return cekimlerLayensuru;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.layensuru_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.layensuru_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerLenyensura extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerLenyensura(){
        }

        public static CekimlerLenyensura newInstance(int sectionNumber) {
            CekimlerLenyensura cekimlerLenyensura = new CekimlerLenyensura();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerLenyensura.setArguments(args);
            return cekimlerLenyensura;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.lenyensura_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.lenyensura_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerLiyensur extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerLiyensur(){
        }

        public static CekimlerLiyensur newInstance(int sectionNumber) {
            CekimlerLiyensur cekimlerLiyensur = new CekimlerLiyensur();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerLiyensur.setArguments(args);
            return cekimlerLiyensur;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.liyensur_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.liyensur_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerLayensur extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerLayensur(){
        }

        public static CekimlerLayensur newInstance(int sectionNumber) {
            CekimlerLayensur cekimlerLayensur = new CekimlerLayensur();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerLayensur.setArguments(args);
            return cekimlerLayensur;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.layensur_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.layensur_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerUnsur extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerUnsur(){
        }

        public static CekimlerUnsur newInstance(int sectionNumber) {
            CekimlerUnsur cekimlerUnsur = new CekimlerUnsur();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerUnsur.setArguments(args);
            return cekimlerUnsur;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.unsur_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.unsur_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerLatensur extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerLatensur(){
        }

        public static CekimlerLatensur newInstance(int sectionNumber) {
            CekimlerLatensur cekimlerLatensur = new CekimlerLatensur();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerLatensur.setArguments(args);
            return cekimlerLatensur;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.latensur_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.latensur_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerMenserun extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerMenserun(){
        }

        public static CekimlerMenserun newInstance(int sectionNumber) {
            CekimlerMenserun cekimlerMenserun = new CekimlerMenserun();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerMenserun.setArguments(args);
            return cekimlerMenserun;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.menserun_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.menserun_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerMinserun extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerMinserun(){
        }

        public static CekimlerMinserun newInstance(int sectionNumber) {
            CekimlerMinserun cekimlerMinserun = new CekimlerMinserun();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerMinserun.setArguments(args);
            return cekimlerMinserun;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.minserun_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.minserun_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerNasreten extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerNasreten(){
        }

        public static CekimlerNasreten newInstance(int sectionNumber) {
            CekimlerNasreten cekimlerNasreten = new CekimlerNasreten();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerNasreten.setArguments(args);
            return cekimlerNasreten;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.nasreten_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.nasreten_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerNisreten extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerNisreten(){
        }

        public static CekimlerNisreten newInstance(int sectionNumber) {
            CekimlerNisreten cekimlerNisreten = new CekimlerNisreten();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerNisreten.setArguments(args);
            return cekimlerNisreten;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.nisreten_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.nisreten_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerNuseyrun extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerNuseyrun(){
        }

        public static CekimlerNuseyrun newInstance(int sectionNumber) {
            CekimlerNuseyrun cekimlerNuseyrun = new CekimlerNuseyrun();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerNuseyrun.setArguments(args);
            return cekimlerNuseyrun;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.nuseyrun_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.nuseyrun_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerNasriyyun extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerNasriyyun(){
        }

        public static CekimlerNasriyyun newInstance(int sectionNumber) {
            CekimlerNasriyyun cekimlerNasriyyun = new CekimlerNasriyyun();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerNasriyyun.setArguments(args);
            return cekimlerNasriyyun;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.nasriyyun_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.nasriyyun_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerNassarun extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerNassarun(){
        }

        public static CekimlerNassarun newInstance(int sectionNumber) {
            CekimlerNassarun cekimlerNassarun = new CekimlerNassarun();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerNassarun.setArguments(args);
            return cekimlerNassarun;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.nassarun_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.nassarun_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerEnsaru extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerEnsaru(){
        }

        public static CekimlerEnsaru newInstance(int sectionNumber) {
            CekimlerEnsaru cekimlerEnsaru = new CekimlerEnsaru();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerEnsaru.setArguments(args);
            return cekimlerEnsaru;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.ensaru_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.ensaru_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerMaensarahu extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerMaensarahu(){
        }

        public static CekimlerMaensarahu newInstance(int sectionNumber) {
            CekimlerMaensarahu cekimlerMaensarahu = new CekimlerMaensarahu();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerMaensarahu.setArguments(args);
            return cekimlerMaensarahu;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.maensarahu_ekrani, container, false);

            Typeface arabca_font= Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi= (TextView) sayfa.findViewById(R.id.maensarahu_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public static class CekimlerVeensirbihi extends Fragment {
        private static final String ARG_SECTION_NUMBER = "section_number";

        public CekimlerVeensirbihi() {
        }

        public static CekimlerVeensirbihi newInstance(int sectionNumber) {
            CekimlerVeensirbihi cekimlerVeensirbihi = new CekimlerVeensirbihi();
            Bundle args = new Bundle();
            args.putInt(ARG_SECTION_NUMBER, sectionNumber);
            cekimlerVeensirbihi.setArguments(args);
            return cekimlerVeensirbihi;
        }

        @Nullable
        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
                container, @Nullable Bundle savedInstanceState) {
            View sayfa = inflater.inflate(R.layout.veensirbihi_ekrani, container, false);

            Typeface arabca_font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/araptype.ttf");

            TextView nasara_acilimi = (TextView) sayfa.findViewById(R.id.veensirbihi_acilimi);
            nasara_acilimi.setTypeface(arabca_font);
            return sayfa;
        }
    }

    public class SectionsPagerAdapter extends FragmentPagerAdapter {
        SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            if (position == 0) {
                return CekimlerNasara.newInstance(position + 1);
            } else if (position == 1) {
                return CekimlerYensuru.newInstance(position + 1);
            } else if (position == 2) {
                return CekimlerNasran.newInstance(position + 1);
            } else if (position == 3) {
                return CekimlerFehuvenasirun.newInstance(position + 1);
            } else if (position == 4) {
                return CekimlerVezakemensurun.newInstance(position + 1);
            } else if (position == 5) {
                return CekimlerLemyensur.newInstance(position + 1);
            } else if (position == 6) {
                return CekimlerLemmayensur.newInstance(position + 1);
            } else if (position == 7) {
                return CekimlerMayensuru.newInstance(position + 1);
            } else if (position == 8) {
                return CekimlerLayensuru.newInstance(position + 1);
            } else if (position == 9) {
                return CekimlerLenyensura.newInstance(position + 1);
            } else if (position == 10) {
                return CekimlerLiyensur.newInstance(position + 1);
            } else if (position == 11) {
                return CekimlerLayensur.newInstance(position + 1);
            } else if (position == 12) {
                return CekimlerUnsur.newInstance(position + 1);
            } else if (position == 13) {
                return CekimlerLatensur.newInstance(position + 1);
            } else if (position == 14) {
                return CekimlerMenserun.newInstance(position + 1);
            } else if (position == 15) {
                return CekimlerMinserun.newInstance(position + 1);
            } else if (position == 16) {
                return CekimlerNasreten.newInstance(position + 1);
            } else if (position == 17) {
                return CekimlerNisreten.newInstance(position + 1);
            } else if (position == 18) {
                return CekimlerNuseyrun.newInstance(position + 1);
            } else if (position == 19) {
                return CekimlerNasriyyun.newInstance(position + 1);
            } else if (position == 20) {
                return CekimlerNassarun.newInstance(position + 1);
            } else if (position == 21) {
                return CekimlerEnsaru.newInstance(position + 1);
            } else if (position == 22) {
                return CekimlerMaensarahu.newInstance(position + 1);
            } else {
                return CekimlerVeensirbihi.newInstance(position + 1);
            }
        }
            @Override
            public int getCount () {
                return 24;
            }

            @Override
            public CharSequence getPageTitle ( int position){
                switch (position) {
                    case 0:
                        return getString(R.string.muhtelifenasara_butontext);
                    case 1:
                        return getString(R.string.muhtelifeyensuru_butontext);
                    case 2:
                        return getString(R.string.muhtelifenasran_butontext);
                    case 3:
                        return getString(R.string.muhtelifefehuvenasirun_butontext);
                    case 4:
                        return getString(R.string.muhtelifevezakemensurun_butontext);
                    case 5:
                        return getString(R.string.muhtelifelemyensur_butontext);
                    case 6:
                        return getString(R.string.muhtelifelemmayensur_butontext);
                    case 7:
                        return getString(R.string.muhtelifemayensuru_butontext);
                    case 8:
                        return getString(R.string.muhtelifelayensuru_butontext);
                    case 9:
                        return getString(R.string.muhtelifelenyensura_butontext);
                    case 10:
                        return getString(R.string.muhtelifeliyensur_butontext);
                    case 11:
                        return getString(R.string.muhtelifelayensur_butontext);
                    case 12:
                        return getString(R.string.muhtelifeunsur_butontext);
                    case 13:
                        return getString(R.string.muhtelifelatensur_butontext);
                    case 14:
                        return getString(R.string.muhtelifemenserun_butontext);
                    case 15:
                        return getString(R.string.muhtelifeminserun_butontext);
                    case 16:
                        return getString(R.string.muhtelifenasreten_butontext);
                    case 17:
                        return getString(R.string.muhtelifenisreten_butontext);
                    case 18:
                        return getString(R.string.muhtelifenuseyrun_butontext);
                    case 19:
                        return getString(R.string.muhtelifenasriyyun_butontext);
                    case 20:
                        return getString(R.string.muhtelifenassarun_butontext);
                    case 21:
                        return getString(R.string.muhtelifeensaru_butontext);
                    case 22:
                        return getString(R.string.muhtelifemaensarahu_butontext);
                    case 23:
                        return getString(R.string.muhtelifeveensirbihi_butontext);
                }
                return null;
            }
        }

        @Override
        public void onBackPressed() {
            DrawerLayout drawer = (DrawerLayout) findViewById(R.id.cekim_drawer_layout);
            if (drawer.isDrawerOpen(GravityCompat.START)) {
                drawer.closeDrawer(GravityCompat.START);
            } else {
                super.onBackPressed();
            }
        }


        @SuppressWarnings("StatementWithEmptyBody")
        @Override
        public boolean onNavigationItemSelected(@NonNull MenuItem item) {

            Typeface font = Typeface.createFromAsset(getAssets(), "fonts/araptype.ttf");

            TextView muhtelife = (TextView) findViewById(R.id.menu_muhtelife);
            muhtelife.setTypeface(font);

            TextView mutteride = (TextView) findViewById(R.id.menu_mutteride);
            mutteride.setTypeface(font);

            int id = item.getItemId();

            if (id == R.id.menu_anasayfa) {

            } else if (id == R.id.menu_muhtelife) {
                Intent intent = new Intent(getApplicationContext(), EmsileMuhtelifeAnasayfa.class);
                startActivity(intent);
                finish();
            } else if (id == R.id.menu_mutteride) {
                Intent intent = new Intent(getApplicationContext(), EmsileMutterideAnasayfa.class);
                startActivity(intent);
                finish();
            } else if (id == R.id.menu_cikis) {
                AlertDialog.Builder diyalog = new AlertDialog.Builder(this);
                diyalog.setIcon(android.R.drawable.ic_dialog_alert);
                diyalog.setTitle(R.string.alertdiyalog_uyari);
                diyalog.setCancelable(false);
                diyalog.setMessage(R.string.alertdiyalog_soru);
                diyalog.setPositiveButton(R.string.alertdiyalog_evet,
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                finish();
                            }
                        });
                diyalog.setNegativeButton(R.string.alertdiyalog_hayir, null).show();
            }

            DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.cekim_drawer_layout);
            drawerLayout.closeDrawer(GravityCompat.START);
            return true;
        }
    }

 

 

490 Görüntülenme

2 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user jacerr67
jacerr67
02.09.2022 - 08:11

It is a new idea of self-promotion and generally flows journal work on this promotion idea because they are cheaper. This https://uk.bestessays.com/buy_essays.html is a highly relevant place for business promotion tips from professionals.

picture-32814-1494668919.jpg
fyeilyurt
04.02.2017 - 01:21
  public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();

         if(id==R.id.nav_camera)
        {
            yuruyusOlcerJavaClassFragment yuruyusObject=new yuruyusOlcerJavaClassFragment();
            getSupportFragmentManager().beginTransaction()

                    .replace(R.id.content_main,yuruyusObject)
                    .addToBackStack(null)
                    .commit();

        }

 

Dediğinizi tam anlamadım ama Fragmentler arası geçiş böyle oluyor.

emrah
04.02.2017 - 11:45
Hocam soruyu güncelledim.
emrah
04.02.2017 - 11:46
i
ferhat yeşilyurt
05.02.2017 - 02:19
nasara.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), CekimlerMain.class); startActivity(intent); getActivity().finish(); } }); Yukarda nasara butonuna tıklayınca yeni aktivity açılması işlemini yapmışsınız. Item değiştirme ile ilgili aşağıdaki atacağım linkten feyizlenebilirsiniz :) http://stackoverflow.com/questions/13383531/viewpager-fragments-change-page-with-button http://stackoverflow.com/questions/28968512/viewpager-set-current-page-programatically
emrah
05.02.2017 - 07:11
teşekkür ederim hocam. Ben bu işte acemiyim. bir türlü anlayamadım